package com.kandinfo.base.admin.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;

import com.kandinfo.base.admin.domain.WorkGroup;
import com.kandinfo.base.common.repository.BaseRepository;


/**
 * Class Name: WorkGroupRepository Description: 工作组
 * 
 * @author wandongwang
 *
 */
public interface WorkGroupRepository extends BaseRepository<WorkGroup, Long> {

    @Query(value = "select * from work_group where name = ?1 ", nativeQuery = true)
    List<WorkGroup> checkName(String name);

    @Query(value = "select *  from work_group g, user_group ug where g.id=ug.group_id and  ug.user_id = ?1",
            nativeQuery = true)
    List<WorkGroup> findGroupbyUserId(Long id);

    @Query(value = "select *  from work_group g, user_group ug where g.id=ug.group_id and  ug.user_id = ?1 limit 1",
            nativeQuery = true)
    WorkGroup findOneGroupbyUser(Long id);
}
